import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import {HashRouter as Router,Switch,Route,Redirect}from 'react-router-dom';
import App from './App';
import reportWebVitals from './reportWebVitals';
import {mainRoutes} from './routes'
import store from './util/storage'
import rootReucer from './store/redux/index'
import {Provider} from 'react-redux'
ReactDOM.render(
  <Provider store={rootReucer}>
 <Router>
     <Switch>
       <Route path='/admin' render={routerProps=><App {...routerProps} />}/>
    {
      mainRoutes.map(route=>{
        return <Route key={route.path} path={route.path} component={route.component}/>;
      })
    }
     <Redirect to='/admin' from='/'></Redirect>
    <Redirect to='/404'></Redirect>
     </Switch>
 </Router>
 </Provider>
 ,
  document.getElementById('root')
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
